<?php

/**
 * Created by PhpStorm.
 * User: fanfzj
 * Date: 2015/3/31
 * Time: 20:01
 */
class Aboutme_model extends CI_Model
{

    var $sina_href = '';
    var $sina_title = '';
    var $qq = '';
    var $email = '';
    var $qq_zone_href = '';
    var $qq_zone_title = '';
    var $renren_href = '';
    var $renren_title = '';
    var $introduce_me = '';
    var $sign = '';
    var $city = '';
    var $school = '';
    var $college = '';
    var $field = '';
    var $photo = '';
    var $my_photo = '';

    function __construct()
    {
        parent::__construct();
    }

    function show_me_info()
    {
        //$this->db->cache_on();
        $query = $this->db->get('about_me');
        $data = $query->row_array();
        //cho $this->db->last_query();
        //echo var_dump($data);
        return $data;
    }
    /*更新我的头像*/
    /*添加更新我的头像记录失败，日志信息添加功能 2015-5-1*/
    function upload_photo($photo_href)
    {
        $data = array(
            'photo' => $photo_href
        );
        $bool = $this->db->update('about_me', $data, array('Id' => '1'));
        if ($bool) {
            //更新成功
            echo "1";
        } else {
            //数据异常
            $system_blog = array(
                'text' => '上传头像，记录失败。路径更新为' . $photo_href . ',sql:' . $this->db->last_query(),
                'date' => date('Y-m-d')
            );
            $this->db->insert('system_blog', $system_blog);
            echo "-1";
        }
    }

    function show_photo()
    {
        $bool = $this->db->get('about_me')->row_array();
        return $bool;
    }
    /*更新关于我*/
    /*添加更新关于我记录失败，日志信息添加功能 2015-5-1*/
    function upset_me_info($sina_href, $sina_title, $qq, $email, $qq_zone_href, $qq_zone_title, $renren_href, $renren_title, $introduce_me, $sign, $school, $college, $field, $city)
    {
        $data = array(
            'sina_href' => $sina_href,
            'sina_title' => $sina_title,
            'qq_zone_href' => $qq_zone_href,
            'qq_zone_title' => $qq_zone_title,
            'qq' => $qq,
            'email' => $email,
            'introduce_me' => $introduce_me,
            'renren_href' => $renren_href,
            'renren_title' => $renren_title,
            'sign' => $sign,
            'school' => $school,
            'college' => $college,
            'field' => $field,
            'city' => $city
        );
        $this->db->where('id', '1');
        $bool = $this->db->update('about_me', $data);
        if ($bool) {
            //更新成功
            echo "1";
        } else {
            //数据异常
            $system_blog = array(
                'text' => '更新关于我，记录失败。修改的数据为：' . json_encode($data) . ',sql:' . $this->db->last_query(),
                'date' => date('Y-m-d')
            );
            $this->db->insert('system_blog', $system_blog);
            echo "-1";
        }

    }

}
